import { Request, Response } from 'express';

const waitTime = (time: number = 100) => {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve(true);
    }, time);
  });
};

export default {
  'get /api/index/navMenu': async (req: Request, res: Response) => {
    await waitTime(4000);
    res.json({
      code: 200,
      success: true,
      resp: [
        {
          name: '小米手机',
          children: [
            {
              name: '小米11',
              price: '3999起',
              pic:
                'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/963679eaf3937351e154600ab3448460.png',
              type: 'phone',
              id: 11,
            },
            {
              name: '小米11',
              price: '3999起',
              pic:
                'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/963679eaf3937351e154600ab3448460.png',
              type: 'phone',
              id: 11,
            },
            {
              name: '小米11',
              price: '3999起',
              pic:
                'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/963679eaf3937351e154600ab3448460.png',
              type: 'phone',
              id: 11,
            },
            {
              name: '小米11',
              price: '3999起',
              pic:
                'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/963679eaf3937351e154600ab3448460.png',
              type: 'phone',
              id: 11,
            },
            {
              name: '小米11',
              price: '3999起',
              pic:
                'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/963679eaf3937351e154600ab3448460.png',
              type: 'phone',
              id: 11,
            },
          ],
        },
        {
          name: 'Redmi 红米',
          children: [
            {
              name: 'Redmi Note 9系列',
              price: '999起',
              pic:
                'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/584add2c9cfdb9eefe7b642bf191773a.png',
              type: 'phone',
              id: 12,
            },
            {
              name: 'Redmi Note 9系列',
              price: '999起',
              pic:
                'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/584add2c9cfdb9eefe7b642bf191773a.png',
              type: 'phone',
              id: 12,
            },
            {
              name: 'Redmi Note 9系列',
              price: '999起',
              pic:
                'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/584add2c9cfdb9eefe7b642bf191773a.png',
              type: 'phone',
              id: 12,
            },
            {
              name: 'Redmi Note 9系列',
              price: '999起',
              pic:
                'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/584add2c9cfdb9eefe7b642bf191773a.png',
              type: 'phone',
              id: 12,
            },
            {
              name: 'Redmi Note 9系列',
              price: '999起',
              pic:
                'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/584add2c9cfdb9eefe7b642bf191773a.png',
              type: 'phone',
              id: 12,
            },
            {
              name: 'Redmi Note 9系列',
              price: '999起',
              pic:
                'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/584add2c9cfdb9eefe7b642bf191773a.png',
              type: 'phone',
              id: 12,
            },
          ],
        },
        {
          name: '电视',
          children: [
            {
              name: '小米电视大师 82英寸至尊纪念版',
              price: '49999元',
              pic:
                'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/174a2f9256a44b98f9e08bbe30528329.png',
              type: 'tv',
              id: 11,
            },
            {
              name: '小米电视大师 82英寸至尊纪念版',
              price: '49999元',
              pic:
                'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/174a2f9256a44b98f9e08bbe30528329.png',
              type: 'tv',
              id: 11,
            },
            {
              name: '小米电视大师 82英寸至尊纪念版',
              price: '49999元',
              pic:
                'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/174a2f9256a44b98f9e08bbe30528329.png',
              type: 'tv',
              id: 11,
            },
            {
              name: '小米电视大师 82英寸至尊纪念版',
              price: '49999元',
              pic:
                'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/174a2f9256a44b98f9e08bbe30528329.png',
              type: 'tv',
              id: 11,
            },
            {
              name: '小米电视大师 82英寸至尊纪念版',
              price: '49999元',
              pic:
                'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/174a2f9256a44b98f9e08bbe30528329.png',
              type: 'tv',
              id: 11,
            },
            {
              name: '小米电视大师 82英寸至尊纪念版',
              price: '49999元',
              pic:
                'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/174a2f9256a44b98f9e08bbe30528329.png',
              type: 'tv',
              id: 11,
            },
          ],
        },
        {
          name: '笔记本',
          children: [
            {
              name: 'Redmi G 游戏本',
              pic:
                'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/0bfdd3b985b4a9da58a1f5a861c5895f.png',
              type: 'notebook',
              id: 11,
            },
            {
              name: 'RedmiBook 16',
              price: '4699元起',
              pic:
                'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/3e6c9a677acbb3b0c75d4d0d83e8a695.png',
              type: 'notebook',
              id: 11,
            },
            {
              name: 'RedmiBook 16',
              price: '4699元起',
              pic:
                'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/3e6c9a677acbb3b0c75d4d0d83e8a695.png',
              type: 'notebook',
              id: 11,
            },
            {
              name: 'RedmiBook 16',
              price: '4699元起',
              pic:
                'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/3e6c9a677acbb3b0c75d4d0d83e8a695.png',
              type: 'notebook',
              id: 11,
            },
            {
              name: 'RedmiBook 16',
              price: '4699元起',
              pic:
                'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/3e6c9a677acbb3b0c75d4d0d83e8a695.png',
              type: 'notebook',
              id: 11,
            },
            {
              name: 'RedmiBook 16',
              price: '4699元起',
              pic:
                'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/3e6c9a677acbb3b0c75d4d0d83e8a695.png',
              type: 'notebook',
              id: 11,
            },
          ],
        },
        {
          name: '家电',
          children: [
            {
              name: '米家互联网空调C1（一级能效）',
              pic:
                'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/03dc85cd792904ddc8027b2d781beed8.png',
              price: '2399元',
              type: 'jd',
              id: 13,
            },
            {
              name: '米家互联网空调C1（一级能效）',
              pic:
                'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/03dc85cd792904ddc8027b2d781beed8.png',
              price: '2399元',
              type: 'jd',
              id: 13,
            },
            {
              name: '米家互联网空调C1（一级能效）',
              pic:
                'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/03dc85cd792904ddc8027b2d781beed8.png',
              price: '2399元',
              type: 'jd',
              id: 13,
            },
            {
              name: '米家互联网空调C1（一级能效）',
              pic:
                'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/03dc85cd792904ddc8027b2d781beed8.png',
              price: '2399元',
              type: 'jd',
              id: 13,
            },
            {
              name: '米家互联网空调C1（一级能效）',
              pic:
                'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/03dc85cd792904ddc8027b2d781beed8.png',
              price: '2399元',
              type: 'jd',
              id: 13,
            },
            {
              name: '米家互联网空调C1（一级能效）',
              pic:
                'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/03dc85cd792904ddc8027b2d781beed8.png',
              price: '2399元',
              type: 'jd',
              id: 13,
            },
          ],
        },
        {
          name: '路由器',
          children: [
            {
              name: '小米路由器AX6000',
              pic:
                'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/2a759fa795d749f0538cfd2a15890027.png',
              price: '599元',
              type: 'ly',
              id: 13,
            },
            {
              name: '小米路由器AX6000',
              pic:
                'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/2a759fa795d749f0538cfd2a15890027.png',
              price: '599元',
              type: 'ly',
              id: 13,
            },
            {
              name: '小米路由器AX6000',
              pic:
                'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/2a759fa795d749f0538cfd2a15890027.png',
              price: '599元',
              type: 'ly',
              id: 13,
            },
            {
              name: '小米路由器AX6000',
              pic:
                'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/2a759fa795d749f0538cfd2a15890027.png',
              price: '599元',
              type: 'ly',
              id: 13,
            },
            {
              name: '小米路由器AX6000',
              pic:
                'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/2a759fa795d749f0538cfd2a15890027.png',
              price: '599元',
              type: 'ly',
              id: 13,
            },
            {
              name: '小米路由器AX6000',
              pic:
                'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/2a759fa795d749f0538cfd2a15890027.png',
              price: '599元',
              type: 'ly',
              id: 13,
            },
          ],
        },
        {
          name: '智能硬件',
          children: [
            {
              name: '小米全自动智能门锁',
              pic:
                'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/2a759fa795d749f0538cfd2a15890027.png',
              price: '1799元',
              type: 'zn',
              id: 13,
            },
            {
              name: '小米全自动智能门锁',
              pic:
                'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/2a759fa795d749f0538cfd2a15890027.png',
              price: '1799元',
              type: 'zn',
              id: 13,
            },
            {
              name: '小米全自动智能门锁',
              pic:
                'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/2a759fa795d749f0538cfd2a15890027.png',
              price: '1799元',
              type: 'zn',
              id: 13,
            },
            {
              name: '小米全自动智能门锁',
              pic:
                'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/2a759fa795d749f0538cfd2a15890027.png',
              price: '1799元',
              type: 'zn',
              id: 13,
            },
            {
              name: '小米全自动智能门锁',
              pic:
                'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/2a759fa795d749f0538cfd2a15890027.png',
              price: '1799元',
              type: 'zn',
              id: 13,
            },
          ],
        },
        {
          name: '服务',
          url: 'https://www.mi.com/service',
          children: [],
        },
        {
          name: '社区',
          url: 'https://www.xiaomi.cn/',
          children: [],
        },
      ],
      msg: null,
    });
  },
  'get /api/index/slideData': async (req: Request, res: Response) => {
    await waitTime(4000);
    res.json({
      code: 200,
      success: true,
      resp: [
        {
          pic:
            'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/1d59dba816517e804251fd031963032d.jpg',
          id: 10000267,
        },
        {
          pic:
            'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/6a60c7eb2229733d85d8b4aea3be4ddd.jpg',
          id: 10000268,
        },
        {
          pic:
            'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/9ebff5f5c1f52f2dbdd611897adbefd4.jpg',
          id: 10000269,
        },
        {
          pic:
            'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/0ef4160c861b998239bce9adb82341e7.jpg',
          id: 10000270,
        },
      ],
      msg: null,
    });
  },
  'get /api/index/mainMenu': async (req: Request, res: Response) => {
    await waitTime(4000);
    const subMenuArr01 = [];
    for (let i = 0; i < 24; i++) {
      subMenuArr01.push({
        name: '小米11',
        pic:
          'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/a51c1afa4db8e47e62fad1f6fa4a8970.png',
        url: 'https://www.mi.com/mi11',
      });
    }
    const subMenuArr02 = [];
    for (let i = 0; i < 15; i++) {
      subMenuArr02.push({
        name: '小米11',
        pic:
          'https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/a51c1afa4db8e47e62fad1f6fa4a8970.png',
        url: 'https://www.mi.com/mi11',
      });
    }
    res.json({
      code: 200,
      success: true,
      resp: [
        {
          name: '手机 电话卡',
          url: 'https://www.mi.com/p/1915.html',
          children: subMenuArr01,
        },
        {
          name: '电视 盒子',
          url: 'https://www.mi.com/p/1915.html',
          children: subMenuArr01,
        },
        {
          name: '笔记本 显示器',
          url: 'https://www.mi.com/p/1915.html',
          children: subMenuArr02,
        },
        {
          name: '家电 插线板',
          url: 'https://www.mi.com/p/1915.html',
          children: subMenuArr02,
        },
        {
          name: '出行 穿戴',
          url: 'https://www.mi.com/p/1915.html',
          children: subMenuArr02,
        },
        {
          name: '智能 路由',
          url: 'https://www.mi.com/p/1915.html',
          children: subMenuArr02,
        },
        {
          name: '电源 配件',
          url: 'https://www.mi.com/p/1915.html',
          children: subMenuArr02,
        },
        {
          name: '健康 儿童',
          url: 'https://www.mi.com/p/1915.html',
          children: subMenuArr02,
        },
        {
          name: '耳机 音响',
          url: 'https://www.mi.com/p/1915.html',
          children: subMenuArr02,
        },
        {
          name: '生活 箱包',
          url: 'https://www.mi.com/p/1915.html',
          children: subMenuArr02,
        },
      ],
      msg: null,
    });
  },
};
